home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c++
- Subject: Re: Urgent help needed
- Date: Tue, 06 Feb 1996 18:04:20 +0200
- Organization: Carelcomp Forest
- Message-ID: <31177C04.741C@cmt.lpr.mail.carel.fi>
- References: <4f6v9o$ov6@otis.netspace.net.au>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (WinNT; I)
-
- Patrick Liang wrote:
- >
- > I am doing a program to convert a serial no to date format, the serial no is
- > representing the seconds elapsed since 01/01/1970. and I using the Visual basic
- > to call the DLL function(general from Borland C++ version 4).
- >
- > It seems there is no problem to creat the DLL in c
- > program, no error message, but when I run the visual basic program which call the
- > DLL that I created, it generate the GPF(general protection fault). the following
- > is the program code.
- >
- > Please help . Thank you.
- >
- > /* This is the def file in C Using Borland C++ */
- >
- > LIBRARY TEST3
- > DESCRIPTION "just testing"
- > EXETYPE WINDOWS
- > CODE PRELOAD MOVEABLE DISCARDABLE
- > DATA PRELOAD MOVEABLE SINGLE
- > HEAPSIZE 4096
- > EXPORTS NUMTODATE
- >
- > /* this is the main c program Using Borland C++ */
- >
- > /* Demonstrates the functions */
- >
- > #include <stdio.h>
- > #include <time.h>
- > #include <stdlib.h>
- > #include <windows.h>
- >
- > char FAR PASCAL NUMTODATE(char *argv1)
- > {
- >
- > struct tm *ptr;
- > char *c, buf1[80];
- > long l;
- >
- > l = atol(argv1);
- >
- > ptr = localtime(&l);
- >
- > c = asctime(ptr);
- > puts(c);
- >
- > return *c;
- > }
- >
- > /* this is the visual basic program */
- >
- >
- > Declare Function NUMTODATE Lib "c:\test3.dll" (ByVal DateNum As String) As String
- >
- > MsgRtn = NUMTODATE(CodeInquire)
- >
- > =============================
-
- In C code, you don't have strings; you have pointers. Also, C tends to use ASCIIZ strings (ie.
- the characters of the 'string' followed by a byte that has a zero value) while in Basic, the
- strings are constructed something like <length><characters>. You could declare the parameter as
- a pointer and select which one of your routines is to handle it (C handling <length><characters>
- strings, or Basic handling <characters><null-byte> strings). Remember to take into account the
- memory model; pointers are handled differently in different models.
-
- Later,
- AriL
- --
- All my opinions are mine and mine alone.
-